import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"
import LoginVue from "@/views/Login.vue"
import RegisterVue from "@/views/Register.vue"
import HomeVue from "@/views/Home.vue"
import UserVue from "@/views/subs/User.vue"
import NotFound from "@/views/NotFound.vue"

const routes: Array<RouteRecordRaw> = [
    {
        path: "/login",
        component: LoginVue,
        meta: {
            keepalive: false
        }
    },
    {
        path: "/register",
        component: RegisterVue
    },
    {
        path: "/home",
        component: HomeVue,
        children: [
            {
                path: "user",
                component: UserVue
            }
        ]
    },
    {
        path: '/:pathMatch(.*)',
        redirect: '/404',
    },
    {
        path: '/404',
        name: '/404',
        component: NotFound
    }
]

const router = createRouter({
    routes,
    history: createWebHistory()
})

export default router
